package com.xiaofei.demo.concurrent_beauty.ch6_lockExample;

import java.util.concurrent.locks.LockSupport;

public class LockSupportExample {


    public static void main(String[] args) {
        System.out.println("begin park");
        LockSupport.unpark(Thread.currentThread());
        // LockSupport.park();
        System.out.println("end park");
        Thread tempThread = new Thread(new Runnable(){
            @Override
            public void run() {
                // TODO Auto-generated method stub
             System.out.println("child thread begin park;");
             LockSupport.park();
             System.out.println("child thread end park;");   
            }
        });
        tempThread.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println("main thread unpark");
        LockSupport.unpark(tempThread);
    }
}
